package com.randi.system.service.impl;

import com.randi.common.enums.excel.ExportStatus;
import com.randi.common.utils.uuid.IdUtils;
import com.randi.system.service.ISysExportService;
import com.randi.system.service.ThreadExportService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author ziye
 */
@Service
public class SysExportServiceImpl<T> implements ISysExportService<T> {

    @Resource
    private ThreadExportService<T> threadExportService;

    /**
     * 校验导出状态
     *
     * @param taskId taskId
     * @return 导出状态
     */
    @Override
    public ExportStatus checkExport(String taskId) {
        return threadExportService.getExportStatus(taskId);
    }

    /**
     * 创建导出数据
     *
     * @param clazz clazz
     * @param list  list
     * @return taskId
     */
    @Override
    public String createExport(Class<T> clazz, List<T> list) {
        String taskId = IdUtils.fastSimpleUUID();
        threadExportService.createDefaultExport(clazz, list, taskId);
        return taskId;
    }

}
